X-Git-Url: https://git.r.bdr.sh/rbdr/Flat-Bezel.qsplugin/blobdiff_plain/fc2c05420021064af5e322f5e59cf0995239349a..953623b990fb65a0a9676071022ae8ce50436d53:/Flat%20Bezel/BBSearchObjectView.m diff --git a/Flat Bezel/BBSearchObjectView.m b/Flat Bezel/BBSearchObjectView.m index ba88b0b..0722e0c 100644 --- a/Flat Bezel/BBSearchObjectView.m +++ b/Flat Bezel/BBSearchObjectView.m @@ -169,8 +169,33 @@ [titleString drawInRect:centerRectInRect(centerRect, textDrawRect)]; } -@end - - - +- (void)drawSearchPlaceholderWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { + NSString *defaultText = NSLocalizedStringWithDefaultValue(@"Type to search", nil, [NSBundle mainBundle], @"Type to search", @"Hint that appears in the first pane of the QS interface when it's empty."); + NSSize textSize = [defaultText sizeWithAttributes:nameAttributes]; + NSRect textRect = centerRectInRect(rectFromSize(textSize), cellFrame); + BOOL isFirstResponder = [[controlView window] firstResponder] == controlView && ![controlView isKindOfClass:[NSTableView class]]; + + if (isFirstResponder && [controlView isKindOfClass:[QSSearchObjectView class]]) { + NSImage *find = [NSImage imageWithSystemSymbolName:@"magnifyingglass.circle.fill" accessibilityDescription:nil]; + + + [find setSize:QSSize16]; + NSRect findImageRect = expelRectFromRectOnEdge(centerRectInRect(rectFromSize([find size]), cellFrame), textRect, NSRectEdgeMinX, -2); + + + NSGraphicsContext *graphicsContext = [NSGraphicsContext currentContext]; + [graphicsContext saveGraphicsState]; + CGContextRef context = [graphicsContext CGContext]; + CGContextBeginTransparencyLayerWithRect(context, findImageRect, nil); + CGContextSetBlendMode(context, kCGBlendModeNormal); + [find drawInRect:findImageRect fromRect:rectFromSize([find size]) operation:NSCompositingOperationSourceOver fraction:1]; + CGContextSetBlendMode(context, kCGBlendModeSourceIn); + CGContextSetFillColorWithColor(context, [[NSColor textColor] CGColor]); + CGContextFillRect(context, findImageRect); + CGContextEndTransparencyLayer(context); + + [defaultText drawInRect:textRect withAttributes:nameAttributes]; + } +} +@end